package cn.pw.test.com.news.adapter;

import android.view.View;

import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import cn.pw.test.com.news.R;
import cn.pw.test.com.news.bean.ArticleBean;

import static cn.pw.test.com.news.manager.NewsPathManger.NEWS_ARTICLE_DETAIL;
import static cn.pw.test.com.news.manager.NewsPathManger.NEWS_ARTICLE_KEY;

public class SchoolNewsAdapter extends BaseQuickAdapter<ArticleBean, BaseViewHolder> {

    public SchoolNewsAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, final ArticleBean item) {
        helper.setText(R.id.school_news_item_title, item.getPost_title());

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ARouter.getInstance().build(NEWS_ARTICLE_DETAIL)
                        .withInt(NEWS_ARTICLE_KEY, item.getId())
                        .navigation();
            }
        });
    }
}
